import { Router } from "express"
import { IcallbackFn, Ioracle } from "../../types"

export default (router: Router, oracle: Ioracle, callbackFn: IcallbackFn) => {
  router.post("/getAccount", (req, res) => {
    const { orgCode,deptCode } = req.body
    let sql = " select * from user_info_n "
    sql += " where (dept like '%" + deptCode + "' "
    sql += " or dept like '%'||substr('"+ deptCode +"',3) and '"+ orgCode +"' = 'CC') "
    sql += " and job_status = 'employed' "
    sql += " and maintain_org = decode('"+ orgCode +"','CT','CM','"+ orgCode +"') "

    callbackFn(res, oracle.connHrm, { sql })
  })

  router.post("/getServerName",(_req,res) => {
    let sql = " select distinct org_code,server_name "
    sql += " from xx_server_manage_header "
    callbackFn(res, oracle.connCcapps, { sql })
  })

  return router
}
